package com.sc.server.member.controller;

import com.sc.server.member.dto.UserDTO;
import com.sc.server.member.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author yuantongqin
 * description:
 * 2020/4/29
 * 由于zuul被gateway 取代，zuul源码不分析了，直接看gateway
 */
@RestController
@Slf4j
public class MemberController {

    @PostMapping("/name")
    public String getMember(@Validated @RequestBody UserDTO name){
        System.out.println(name.getName()+"=="+name.getPassword());
        return "member server "+name;
    }


    @GetMapping(value = "/getName/{id}", produces="application/json;charset=UTF-8")
    public String getName(@PathVariable("id") Long Id){
        log.info("member-server 服务处理 id:"+Id);
        int i = ThreadLocalRandom.current().nextInt(100);
        return "根据id="+Id+" 返回的name=张三"+i;
    }

    @Autowired
    private UserService userService;

    @GetMapping("/hello")
    public String hello(String name){
//        List<UserPO> user = userService.getUser();
        return name+"==你好";
    }
}
